import Reflux from 'reflux';
import PageConst from './PageConst';
import Actions from './Actions';
import nattyStorage from 'natty-storage';
import StorageUtils from './../../../app/storage';
import update from 'react-addons-update';

const storageUser = nattyStorage({
  type: 'localStorage',
  key: 'sskj-wechat',
});




export default Reflux.createStore({
    listenables: [Actions],
    data: {
        ...PageConst,
      userInfo: {
        certNum: '',
        telNum: '',
        vcode: '',
        name:'',
        organName:''
      }
    },

  initMode: function () {
    let t = this;
    this.data.userInfo = update(this.data.userInfo, {$merge: {...StorageUtils.getStorage().get('user')}});
  },

    onFetch: function (params, cb) {
        let t = this;
        t.updateComponent();
        cb && cb(t.data);
    },

    updateComponent: function () {
        this.trigger(this.data);
    },

    getInitialState: function () {
        return this.data;
    }
});
